package com.sun.demo04;

import com.sun.demo02.UserService;
import com.sun.demo02.UserServiceImpl;

/**
 * @Author SunBingRui
 * @Date 2020/5/16 11:27
 */
public class Client {
    public static void main(String[] args) {
        //真实角色
        UserServiceImpl userService = new UserServiceImpl();
        //代理角色,不存在
        ProxyInvocationHandler pih = new ProxyInvocationHandler();
        //设置要代理的对象
        pih.setTarget(userService);
        //动态生成代理对象
        UserService UserServiceProxy = (UserService) pih.getProxy();

        UserServiceProxy.add();
        UserServiceProxy.delete();
        UserServiceProxy.update();
        UserServiceProxy.query();

    }
}
